<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Load Function </title>
</head>

<body>
/**<br />
* <{$functionName}> ,<{$functionDescription}><br />
* <br />
* @param MySQLi $_dbObject  <br />
  <{foreach from=$whereStrs item=pa name=foo}>
* @param $<{$pa->valueName}><br />
  <{/foreach}>
* @return -1 when error, others is the number of the existent records<br />
 */<br />

 function <{$functionName}>(MySQLi $_dbObject
<{foreach from=$whereStrs item=pa name=foo}>
,
$<{$pa->valueName}>
<{/foreach}>){<br />

 

$whereStr=&quot; where 1=1 &quot;;<br />
  <br />
  <{foreach from=$whereStrs item=wStr name=foo}>
   if(isset($<{$wStr->valueName}>) <{if $wStr->singleQuotes=="'"}> &amp;&amp; $<{$wStr->valueName}>!=&quot;&quot;<{/if}>){<br />
$whereStr.=sprintf(&quot; and `<{$wStr->fieldName}>` <{$wStr->operator}> 
   <{$wStr->singleQuotes}><{$wStr->likeHeadStr}><{$wStr->sprintfStr}><{$wStr->likeTailStr}><{$wStr->singleQuotes}>&quot;,
   <{if $wStr->escapeStr==1}>$this-&gt;escape_string(<{/if}>$<{$wStr->valueName}><{if $wStr->escapeStr==1}>)<{/if}>);<br />
<br />
<br />}<br />
<br />
 <{/foreach}>
<br />

$sql=&quot;select 
count(*) 
  <{$joinSql}> <{$tableName}> &quot;.$whereStr;<br />

//echo $sql.&quot;&lt;br //&gt;&quot;;<br />
  <br />
  <br />
  <br />

$result=$_dbObject-&gt;query($sql);<br />
<br />
			$re=0;<br />
<br />
			if($result !==false){<br />
<br />
				if($result-&gt;num_rows&gt;0){<br />
					$row =$result-&gt;fetch_row();<br />
<br />
<br />
					if($row!==NULL){<br />
						<br />
<br />
						$re=$row[0];<br />
					}<br />
				}<br />
				$result-&gt;free();<br />
<br />
			}<br />
			return $re;
<br />
<br />}<br />



<br />
<br /></body>
</html>
